home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 081 / addctrlz.arc / ADDCTRLZ.C next >
Text File  |  1987-08-10  |  2KB  |  83 lines

  1. #include <ctype.h>
  2. #include <dos.h>
  3. #include <stdio.h>
  4.  
  5. main(argc,argv)
  6. int argc;
  7. char *argv[];
  8.  
  9. {
  10. char cdir[32],dirname[32],drve,ex[100][13],sfl[100][13],propdir[32];
  11. struct FIND *sys_files,*findmsg;
  12. int cntt=0,count=0,excs=0,nn=0,scans,syst;
  13. FILE *endmsg;
  14.  
  15.     puts("\nAddCtrlZ [v0.0.0] - Simon Meldrum\n");
  16.     if (!(sys_files=findfirst("SYSTEM??.BBS",0xE7)))
  17.     {
  18.         puts("Can't find any SYSTEM??.BBS files.");
  19.         exit(1);
  20.     }
  21.     do
  22.     {
  23.         strcpy(sfl[cntt++],sys_files->name);
  24.     } while((sys_files=findnext()));
  25.     if (argc>1)
  26.     {
  27.         excs=argc-1;
  28.         do
  29.         {
  30.             strcpy(ex[count],"SYSTEM");
  31.             strcat(ex[count],argv[count+1]);
  32.             strcat(ex[count++],".BBS");
  33.             if (argv[count][0]=='0') strcpy(ex[count-1],"SYSTEM.BBS");
  34.         } while(count<excs);
  35.     }
  36.     getcwd(cdir,32);
  37.     do
  38.     {
  39.         scans=-1;
  40.         for(count=0;count<excs;count++)
  41.         {
  42.             if ((strcmp(ex[count],sfl[nn]))==0) scans=0;
  43.         }
  44.         syst=open(sfl[nn++],O_RDONLY);
  45.         lseek(syst,0x4L,0);
  46.         read(syst,dirname,32);
  47.         close(syst);
  48.         if (scans && (dirname[0]=='\\' || isalpha(dirname[0])))
  49.         {
  50.             drve=0;
  51.             if (dirname[0]!='\\')
  52.             {
  53.                 drve=dirname[0];
  54.                 rightcopy(propdir,dirname);
  55.                 strcpy(dirname,propdir);
  56.             }
  57.             if (dirname[1]!=0) dirname[strlen(dirname)-1]=0;
  58.             chdir(dirname);
  59.             if ((findmsg=findfirst("*.MSG",0xE7)))
  60.             {
  61.                 do
  62.                 {
  63.                     printf("%s\\%s\n",dirname,findmsg->name);
  64.                     endmsg=fopen(findmsg->name,"a+b");
  65.                     fseek(endmsg,0L,2);
  66.                     putc(26,endmsg);
  67.                     fclose(endmsg);
  68.                 } while((findmsg=findnext()));
  69.             }
  70.         }
  71.         chdir(cdir);
  72.     } while(nn<cntt);
  73.     puts("\nAddCtrlZ completed...");
  74.     exit(0);
  75. }
  76.  
  77. rightcopy(d,s)
  78. char *d,*s;
  79. {
  80.     while(*d++ = *(2+s++));
  81. }
  82.  
  83.